home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / QuickDraw GX / QuickDraw GX Info / QuickDraw GX Interfaces / Interfaces & Libraries / graphics libraries / user library.c < prev   
Encoding:
C/C++ Source or Header  |  1994-04-30  |  1.5 KB  |  64 lines  |  [TEXT/MPS ]

  1. /* graphics libraries:
  2.     user library
  3.     by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
  4.     Copyright 1987 - 1991 Apple Computer, Inc.  All rights reserved.    */
  5.  
  6. #include "graphics libraries.h"
  7.  
  8.  
  9. void DisposeTagAt(gxTag *oldTag)
  10. {
  11.     NilParamReturn(oldTag);
  12.     if (*oldTag) {
  13.         GXDisposeTag(*oldTag);
  14.         *oldTag = nil;
  15.     }
  16. }
  17.  
  18. void AddShapeUser(gxShape source, const void *data, long length, long type)
  19. {
  20.     gxTag tempItem;
  21.  
  22.     tempItem = GXNewTag(type, length, data);
  23.     GXSetShapeTags(source, 0, 0, 0, 1, &tempItem);
  24.     GXDisposeTag(tempItem);
  25. }
  26.  
  27. long GetShapeUser(gxShape source, void *data, long *length, long requestedType, long *foundType, long index)
  28. {
  29.     if( length )
  30.         *length = 0;
  31.  
  32.     if( index )
  33.     {
  34.         gxTag tempItem;
  35.  
  36.         if( GXGetShapeTags(source, requestedType, index, 1, &tempItem) )
  37.         {
  38.             register long tempLength;
  39.  
  40.             tempLength = GXGetTag(tempItem, foundType, data);
  41.             if( length )
  42.                 *length = tempLength;
  43.             return index;
  44.         }
  45.  
  46.         return 0;
  47.     }
  48.     else
  49.         return GXGetShapeTags(source, requestedType, 1, gxSelectToEnd, nil);
  50. }
  51.  
  52. void RemoveShapeUser(gxShape source, long type, long index)
  53. {
  54.     register long count = 1;
  55.  
  56.     if( index == 0 )        /* remove all user items of the specified type */
  57.     {
  58.         count = gxSelectToEnd;
  59.         index = 1;
  60.     }
  61.  
  62.     GXSetShapeTags(source, type, index, count, 0, nil);
  63. }
  64.